<template>
    <el-card shadow="never" class="!border-none">
        <router-link
            :to="{
                path: getRoutePath('marketing.printertemplate.add')
            }"
            ><el-button type="primary">新增小票模板</el-button>
        </router-link>
        <el-table size="large" :data="pager.lists" class="mt-[14px]">
            <el-table-column prop="template_name" label="模板名称" />
            <el-table-column prop="equipment_num" label="关联设备" />
            <el-table-column prop="create_time" label="创建时间" />
            <el-table-column label="操作" fixed="right">
                <template #default="{ row }">
                    <el-button type="primary" @click="handleEdit(row)">
                        <router-link
                            :to="{
                                path: getRoutePath('marketing.printertemplate.add'),
                                query: {
                                    id: row.id
                                }
                            }"
                        >
                            编辑
                        </router-link>
                    </el-button>
                    <el-button
                        v-if="row.root != 1"
                        type="danger"
                        link
                        @click="handleDelete(row.id)"
                    >
                        删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="flex justify-end mt-4">
            <pagination v-model="pager" @change="getLists" />
        </div>
    </el-card>
    <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue'
import { usePaging } from '@/hooks/usePaging'
import { printerStatus, deltemplate, gettemplatelists } from '@/api/application'
import feedback from '@/utils/feedback'
// import EditPopup from './edit.vue'
import { getRoutePath } from '@/router'

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: gettemplatelists
})
getLists()
const handleChange = async (params: any) => {
    await printerStatus(params)
}
const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await deltemplate({ id })
    getLists()
}
//展开edit
const showEdit = ref(false)

const handleEdit = async (data: any) => {
    console.log(111)
}
</script>

<style lang="scss" scoped></style>
